import { Router, Route, Switch, Redirect } from "react-router-dom";
// 注意：此处需要导入 Router
import { customHistory } from "./utils/history";
// 导入页面组件
import Login from "./pages/Login";
import Layout from "./pages/Layout";
import Personal from "@/pages/personal";
import { AuthRoute } from "./components/AuthRoute";
import Search from "./pages/search";
import result from "./pages/Result/result";
import Article from "./pages/Article";
import Chat from "./pages/Chat";
// 配置路由规则

function App() {
  return (
    <Router history={customHistory}>
      <div className="app">
        <Switch>
          <Route
            exact
            path={"/"}
            render={() => <Redirect to={"/home/index"} />}
          ></Route>
          <Route path={"/home"} component={Layout}></Route>
          <Route path={"/login"} component={Login}></Route>
          <AuthRoute path="/profile/personal">
            {" "}
            <Personal />{" "}
          </AuthRoute>
          <Route path={"/search"} component={Search}></Route>
          <Route path={"/result"} component={result}></Route>
          {/* <Route path={"/articles"} component={Article}></Route> */}
          <AuthRoute path="/articles">
            {" "}
            <Article />{" "}
          </AuthRoute>
          <Route path={"/chat"} component={Chat}></Route>
        </Switch>
      </div>
    </Router>
  );
}
export default App;
